package com.tomcat.myapplication.util;

import android.content.Context;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

/**
 * Created by user on 16-9-5.
 */
public class ToastUtil {

    public static Toast s_toast;

    public static void longToast(Context context, String text){
        if (s_toast == null){
            s_toast = Toast.makeText(context, text, Toast.LENGTH_LONG);
        }else{
            s_toast.setText(text);
        }
        s_toast.setGravity(Gravity.CENTER, 0, 0);
        LinearLayout linearLayout = (LinearLayout) s_toast.getView();
        TextView messageTextView = (TextView) linearLayout.getChildAt(0);
        messageTextView.setTextSize(10);
        s_toast.show();
    }

    public static void shortToast(Context context, String text){
       // if (s_toast == null){
            s_toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
       /* }else{
            s_toast.setText(text);
        }*/
        s_toast.setGravity(Gravity.CENTER, 0, 0);
        LinearLayout linearLayout = (LinearLayout) s_toast.getView();
        TextView messageTextView = (TextView) linearLayout.getChildAt(0);
        messageTextView.setTextSize(10);
        s_toast.show();
    }
}
